home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / Goodies / CallBack / WINDENUM.CLS < prev   
Text File  |  1997-06-09  |  1KB  |  48 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "WindowEnumerator"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = False
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Option Explicit
  11.  
  12. Private m_CallBack As CallBack
  13. Private m_Recurse As Boolean 'Public variables aren't allowed
  14.  
  15. Function WNDENUMPROC(ByVal hWnd As Long, LParam As ListBox) As Long
  16. Dim strTitle As String
  17. Dim iLength As Long
  18.     If IsWindowVisible(hWnd) Then
  19.         strTitle = String$(128, 0)
  20.         iLength = GetWindowText(hWnd, strTitle, 128)
  21.         If iLength Then
  22.             With LParam
  23.                 .AddItem Left$(strTitle, iLength)
  24.                 .ItemData(.NewIndex) = hWnd
  25.             End With
  26.         End If
  27.         If m_Recurse Then EnumChildWindows hWnd, ProcAddress, LParam
  28.     End If
  29.     WNDENUMPROC = 1
  30. End Function
  31.  
  32. Private Sub Class_Initialize()
  33.     Set m_CallBack = NewCallBack(CBType_WNDENUMPROC, Me, True)
  34.     m_Recurse = True
  35. End Sub
  36.  
  37. Public Property Get ProcAddress() As Long
  38.     ProcAddress = m_CallBack.ProcAddress
  39. End Property
  40.  
  41. Public Property Let Recurse(Value As Boolean)
  42.     m_Recurse = Value
  43. End Property
  44.  
  45. Public Property Get Recurse() As Boolean
  46.     Recurse = m_Recurse
  47. End Property
  48.